package com.easybuilder.core.menu.dao;

import com.easybuilder.core.menu.entity.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;

/**
 * @author ZXS
 * @version 1.0
 * @description 接口
 * @date 2021-6-20 14:42
 */
@Repository
public interface MenuDao extends BaseMapper<SysMenu> {

    @Select("<script>" +
                " select * from sys_menu where " +
                " <choose>" +
                "    <when test='parentId == null'> " +
                "       parent_id is null " +
                "    </when> " +
                "    <otherwise>" +
                "       parent_id = #{parentId}  " +
                "    </otherwise>" +
                "</choose>" +
                " order by sort" +
            "</script>")
    List<SysMenu> getByParentId(@Param("parentId") Long parentId);

}
